<meta http-equiv="Content-Type" content="text/html" charset="utf-8" />
<script type="text/javascript">
$(function() {
   $(".close_layer").click(function(){
		$("#sent_notice_mobile").hide();
		$("#sent_notice_email").hide();	
	});

   $("#txtDate").blur(function(){
	   if($("#txtDate").val()==""){
			spanshow("spanDate","要写预约时间");
		}else{
			spanhide("spanDate");
		}
	})
   $("#txtMobile").blur(function() {                 
	   if(!checkmobile($.trim($("#txtMobile").val()))){
		   spanshow("spanMobile","手机号错误或不能为空");
	   }else{
		   spanhide("spanMobile");
	   }
   });  
   
    
   $("#txtsendemail").blur(function() {                 
	   if(!checkemail($.trim($("#txtsendemail").val()))){
		   spanshow("spanEmail","邮箱格式错误");
	   }else{
		   spanhide("spanEmail");
	   }
   });
   
   $("#txtContent1").blur(function() {                 
       if($("#txtContent1").val()==""){
           spanshow("spanContent1","内容必须要写");
       }else if($("#txtContent1").val().length >500){
           spanshow("spanContent1","问题标题不能超过500个字符");
       }else{
           spanhide("spanContent1");
       }
    }); 
   $("#txtContent2").blur(function() {                 
       if($("#txtContent2").val()==""){
           spanshow("spanContent2","内容必须要写");
       }else if($("#txtContent2").val().length >500){
           spanshow("spanContent2","问题标题不能超过500个字符");
       }else{
           spanhide("spanContent2");
       }
    }); 
    $("#txtContent1").keyup(function() {                 
       if($("#txtContent1").val().length >500){
           spanshow("spanContent1","问题内容不能超过500个字符");
       }else{
           spanhide("spanContent1");
       }
    }); 
    $("#txtContent2").keyup(function() {                 
       if($("#txtContent2").val().length >500){
           spanshow("spanContent2","问题内容不能超过500个字符");
       }else{
           spanhide("spanContent2");
       }
    }); 
	
	$("#txtTitle1").blur(function() {                 
       if($("#txtTitle1").val()==""){
           spanshow("spanTitle1","标题必须要写");
       }else if($("#txtTitle1").val().length >50){
           spanshow("spanTitle1","问题标题不能超过50个字符");
       }else{
           spanhide("spanTitle1");
       }
    }); 
	
    $("#txtTitle1").keyup(function() {                 
       if($("#txtTitle1").val().length >50){
           spanshow("spanTitle1","问题标题不能超过50个字符");
       }else{
           spanhide("spanTitle1");
       }
    }); 
	$("#txtTitle2").blur(function() {                 
       if($("#txtTitle2").val()==""){
           spanshow("spanTitle2","标题必须要写");
       }else if($("#txtTitle2").val().length >50){
           spanshow("spanTitle2","问题标题不能超过50个字符");
       }else{
           spanhide("spanTitle2");
       }
    }); 
    $("#txtTitle2").keyup(function() {                 
       if($("#txtTitle2").val().length >50){
           spanshow("spanTitle2","问题标题不能超过50个字符");
       }else{
           spanhide("spanTitle2");
       }
    }); 
    
    $("#btnsave").click(function(){
		if($("#txtDate").val()==""){
			spanshow("spanDate","要写预约时间");
            return false;
		}
        if(!checkmobile($.trim($("#txtMobile").val()))){
			spanshow("spanMobile","手机号错误或不能为空");
            return false;   
        }
        if($("#txtTitle1").val().length >50){
			spanshow("spanTitle1","问题标题不能超过50个字符");
            return false;
        }
		if($("#txtTitle1").val()==""){
           spanshow("spanTitle1","标题必须要写");
		   return false;
       }
	   if($("#txtContent1").val()==""){
           spanshow("spanContent1","内容必须要写");
		   return false;
       }
	   if($("#txtContent1").val().length >500){
           spanshow("spanContent1","问题标题不能超过500个字符");
		   return false;
       }
        mobileadd();
    });
    $("#btnsend").click(function(){ 
        
		if(!checkemail($.trim($("#txtsendemail").val()))){
			spanshow("spanEmail","邮箱格式错误或不能为空");
            return false;
        }
        if($("#txtTitle2").val().length >200){
            
        }
		if($("#txtTitle2").val()==""){
           spanshow("spanTitle2","标题必须要写");
		   return false;
       }
	   if($("#txtTitle2").val().length >50){
           spanshow("spanTitle2","问题标题不能超过50个字符");
		   return false;
	   }
		if($("#txtContent2").val()==""){
           spanshow("spanContent2","内容必须要写");
		   return false;
       }
	   if($("#txtContent2").val().length >500){
           spanshow("spanContent2","问题标题不能超过500个字符");
		   return false;
       }
        emailadd();
    });
    
})



function spanshow(obj,text){
    $("#"+obj).show();
    $("#"+obj).html("<i class='fa fa-times-circle'></i>"+text);    
}

function spanhide(obj){
    $("#"+obj).hide();
    $("#"+obj).html("");    
}

function checkmobile(mobile){
    var reg=/^1[34578]\d{9}$/;
    return reg.test(mobile);
}

function checkemail(email){
    var reg=/([a-z0-9]*[-_\.]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[\.][a-z]{2,3}([\.][a-z]{2})?/i;
    return reg.test(email);
}

//全部清空
function clearall(){
    //清空文本框
    $("#txtDate").val("");
	$("#txtTitle1").val("");
    $("#txtContent1").val("");
    $("#txtTitle2").val("");
    $("#txtContent2").val("");
    $("#txtQuestion").val("");    
}


function mobileadd(){
       var apptime = $("#txtDate").val();
       var appmobile = $.trim($("#txtMobile").val());
       var apptitle = $.trim($("#txtTitle1").val());
       var appcontent = $.trim($("#txtContent1").val());
       
       $.ajax({  
        type: "post",  
        url: "__APP__/Uc/Ask/mobileadd",
        dataType: 'json',
        data: {apptime:apptime,appmobile:appmobile,apptitle:apptitle,appcontent:appcontent,vid:vid},  
        beforeSend: function(XMLHttpRequest){
        },  
        success: function(json){
            if(json.data == 1){
                //$("#btnqx").click();
                //alert(json.info); 
				$("#sent_notice_mobile p").text(json.info);
				$("#sent_notice_mobile").show();
            }else{
                //alert(json.info);
				$("#sent_notice_mobile p").text(json.info);
				$("#sent_notice_mobile").show();
            }
        } 
    })
    clearall();
}


function emailadd(){
    var appemail = $("#txtsendemail").val();
    var apptitle = $.trim($("#txtTitle2").val());
    var appcontent = $.trim($("#txtContent2").val());
    
   $.ajax({  
        type: "post",  
        url: "__APP__/Uc/Ask/emailadd",
        dataType: 'json',
        data: {appemail:appemail,apptitle:apptitle,appcontent:appcontent,vid:vid},  
        beforeSend: function(XMLHttpRequest){
        },  
        success: function(json){
            if(json.data == 1){
                //$("#btnqx").click();
                //alert(json.info);  
				$("#sent_notice_email p").text(json.info);
				$("#sent_notice_email").show();
            }else{
                //alert(json.info); 
				$("#sent_notice_email p").text(json.info);
				$("#sent_notice_email").show();
            }
        } 
    })
    clearall();
}

</script>

<div id="appointment" class="reveal-modal panel large">
    <div class="panel-head">
        预约面谈&nbsp;<span class="text-danger">[700元/小时]</span>
        <a class="close-reveal-modal close_layer">×</a>
    </div>
    <div class="panel-body" style="position:relative">
        <h2 class="align-center">请提前至少48小时预约</h2>
        <div class="layerForm">
            <p>
                <label>预约时间：</label>
                <input type="text" id="txtDate" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd H:mm',minDate:'%y-%M-{%d+2}',disabledDates:['....-..-.. 0[0-9]\:..\:..','....-..-.. 1[6-9]\:..\:..','....-..-.. 2[0-3]\:..\:..']})" class="form-control Wdate" name="" placeholder="选择预约时间" />
                <span class="text-danger">（10:00-16:00）</span>
                <span style="display:none;" class="notice_wrong" id="spanDate"></span>
            </p>
            <p>
                <label>您的手机：</label>
                <input name="" class="form-control" placeholder="手机号" type="text" id="txtMobile" maxlength="11" value="{$mobile}">
                <span style="display:none;" class="notice_wrong" id="spanMobile"></span>
            </p>
            <p>
                <label>咨询主题：</label>
                <input name="" class="form-control" placeholder="咨询主题" type="text" id="txtTitle1" maxlength="200" >
                <span style="display:none;" class="notice_wrong" id="spanTitle1"></span>
            </p>
            <p>
                <label>咨询内容：</label>
                <textarea name="" cols="" rows="" id="txtContent1" placeholder="填写想咨询的问题"></textarea>
                <span style="display:none;" class="notice_wrong" id="spanContent1"></span>
            </p>
            <p style="padding-left:20%;">
                <a class="btn btn-danger" type="button" style="width:20%" id="btnsave">提 交</a>
                <a class="btn btn-success close-reveal-modal" style="width:20%" id="btnqx">取 消</a>
            </p>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
        <div class="send_notice" style="display:none;" id="sent_notice_mobile">
        	<p></p>
        </div>
    </div>
</div>
<div id="askOnLine" class="reveal-modal panel large">
    <div class="panel-head">
        邮件咨询&nbsp;<span class="text-danger">[免费]</span>
        <a class="close-reveal-modal close_layer">×</a>
    </div>
    <div class="panel-body" style="position:relative">
        <div class="layerForm">
            <p>
                <label>发 件 人：</label>
                <input type="text" class="form-control" name="" placeholder="填写您的邮箱地址" id="txtsendemail" value="{$email}"/>
                <span style="display:none;" class="notice_wrong" id="spanEmail"></span>
            </p>
            <!--<p>
                <label>收 件 人：</label>
                <input name="" class="form-control"  type="text" disabled="disabled" id="txtaccemail" />
            </p>-->
            <p>
                <label>咨询主题：</label>
                <input name="" class="form-control" placeholder="填写您的咨询主题" type="text" id="txtTitle2"/>
                <span style="display:none;" class="notice_wrong" id="spanTitle2"></span>
            </p>
            <p>
                <label>咨询内容：</label>
                <textarea name="" cols="" rows="" placeholder="填写您的咨询内容" id="txtContent2"></textarea>
                <span style="display:none;" class="notice_wrong" id="spanContent2"></span>
            </p>
            <p style="padding-left:20%;">
                <a class="btn btn-danger" type="button" style="width:20%" id="btnsend">提  交</a>
                <a class="btn btn-success close-reveal-modal" style="width:20%">取 消</a>
            </p>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
        <div class="send_notice" style="display:none;" id="sent_notice_email">
        	<p>您咨询的问题已收到，我们的顾问会在24小时内回复到您的邮箱！7min团队感谢您的支持！</p>
        </div>
    </div>
</div>